import request from '../utils/request'
export const homeRequest = {
    workDashboard() {
        return request({
            url: '/api/v1/shop/staff/index/my-workbench',
            method: 'GET'
        })
    },
}

export const orderRequest = {
    list({ type, pageNo, pageSize,keyword }) {
        return request({
            url: `/api/v1/order/list`,
            method: 'GET',
            data: {
                type, pageNo, pageSize,keyword
            }
        })
    },
    ignorePrint(orderId) {
        return request({
            url: `/api/v1/order/ignore-print/${orderId}`,
            method: 'POST'
        })
    },
    confirmPrint(orderId) {
        return request({
            url: `/api/v1/order/confirm-print/${orderId}`,
            method: 'POST'
        })
    },
    rollbackPrint(orderId) {
        return request({
            url: `/api/v1/order/confirm-print/${orderId}`,
            method: 'POST'
        })
    }
}

export const payRequest = {
    accountInfo() {
        return request({
            url: '/api/v1/shop/account/me/balance',
            method: 'GET'
        })
    },
    recordList({pageNo,pageSize}) {
        return request({
            url: '/api/v1/shop/account/me/rechargerecord',
            method: 'GET',
            data: {
                pageNo,
                pageSize
            }
        })
    },
    usedList({pageNo,pageSize}) {
        return request({
            url: '/api/v1/shop/account/me/consumptionrecord',
            method: 'GET',
            data: {
                pageNo,
                pageSize
            }
        })
    },
    /**
     * 支付相关
     */
    createOrder({ amount, openId }) {
        return request({
            url: '/api/v1/shop/account/me/recharge',
            method: 'POST',
            data: {
                amount, openId
            }
        })

    },
    askCallbackSuccess(outTradeNo) {
        return request({
            url: '/api/v1/shop/account/wechatpay/verifyPay',
            method: 'POST',
            data: {
                outTradeNo
            }
        })
    }
}

export const userRequest = {
    login(data) {
        return request({
            url: '/api/v1/shop/staff/login',
            method: 'POST',
            data
        })
    },
    updatePassword(data) {
        return request({
            url: '/api/v1/shop/staff/changepassword',
            method: 'POST',
            data
        })
    },
    getUserInfo() {
        return request({
            url: '/api/v1/shop/staff/me',
            method: 'GET'
        })
    },
}

export const systemRequest = {
    getOpenId(code) {
        return request({
            url: '/api/v1/shop/account/wxauth/code2openid',
            method: 'POST',
            data: {
                jsCode: code
            }
        })

    }
}

// 获取客服信息
export const getServiceConf = () => {
    return request({
        url: '/api/v1/conf/website-contact',
        method: 'GET'
    })
}
